<?php


namespace app\api\model;

use app\common\model\LotteryGoods as LotteryGoodsModel;


class LotteryGoods extends LotteryGoodsModel
{
    public static function getByOnline()
    {
        $res = self::_getByOnline();
        if (!$res) {
            return [];
        }
        $arr = [];
        foreach ($res as $key=>$val) {
            $val['file_path'] = $val['image']['file_path'];
            unset($val['image']);
            $arr[$val['id']] = $val;
        }
        return $arr;
    }

    private static function _getByOnline()
    {
        return self::with('image')->where('online', '>', 0)->select()->toArray();
    }
}